//
//  NewFeatureVC.swift
//  kingWeiBo
//
//  Created by King on 15/9/14.
//  Copyright © 2015年 King. All rights reserved.
//

import UIKit

private let reuseIdentifier = "Cell"

class NewFeatureVC: UICollectionViewController {
    
    let layout = KNlayout()
    init(){
        
        super.init(collectionViewLayout: layout)
        view.backgroundColor = UIColor.whiteColor()
    }
    

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.collectionView?.registerClass(NewFeatureCell.self, forCellWithReuseIdentifier: reuseIdentifier)
        
    }
    
    
    override func collectionView(collectionView: UICollectionView, didEndDisplayingCell cell: UICollectionViewCell, forItemAtIndexPath indexPath: NSIndexPath) {
        let path  = collectionView.indexPathsForVisibleItems().last!
        
        if path.item == 3{
            let cell = collectionView.cellForItemAtIndexPath(path) as! NewFeatureCell
            
            cell.startButtonAnimation()
        }
    }
    
    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 4
    }

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier,
                                forIndexPath: indexPath) as! NewFeatureCell
        cell.imageIndex = indexPath.item
        
        return cell
    }


}
